package cn.yshujia.domain.entity;

import cn.yshujia.handler.PrefixHandler;
import cn.yshujia.handler.SensitiveHandler;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * @author YShuJia
 * @create 2024/4/23
 * @description 实体
 */

@Data
@TableName (value = "t_comment", autoResultMap = true)
@Schema (name = "Comment", description = "评论")
public class Comment implements Serializable {
	
	@Serial
	private static final long serialVersionUID = 1L;
	
	@Schema (description = "主键")
	@TableId (value = "id", type = IdType.ASSIGN_ID)
	private Long id;
	
	@Schema (description = "用户ID")
	@TableField ("user_id")
	private Long userId;
	
	@Schema (description = "源ID（评论来源）")
	@TableField ("source_id")
	private Long sourceId;
	
	@Schema (description = "楼层评论（该ID和评论ID相同时无楼层，自己为楼层）")
	@TableField ("floor_id")
	private Long floorId;
	
	@Schema (description = "父评论用户ID（主键和该ID相同时未回复评论）")
	@TableField ("parent_user_id")
	private Long parentUserId;
	
	@Schema (description = "点赞量")
	@TableField ("like_count")
	private Integer likeCount;
	
	@Schema (description = "内容")
	@TableField (value = "content", typeHandler = SensitiveHandler.class)
	private String content;
	
	@Schema (description = "图片地址")
	@TableField (value = "img_url", typeHandler = PrefixHandler.class)
	private String imgUrl;
	
	@Schema (description = "创建时间")
	@TableField (value = "create_time", fill = FieldFill.INSERT)
	@JsonFormat (pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date createTime;
}